Skip to content

buzhash64e: with rolling hash encryption#8920

Draft
ThomasWaldmann wants to merge 3 commits intoborgbackup:masterfrom
ThomasWaldmann:buzhash64enc
Draft

buzhash64e: with rolling hash encryption#8920
ThomasWaldmann wants to merge 3 commits intoborgbackup:masterfrom
ThomasWaldmann:buzhash64enc

Conversation

@ThomasWaldmann
Copy link
Member

@ThomasWaldmann ThomasWaldmann commented Jun 13, 2025

Rather simple and very slow encryption code, needs to be tuned later IF we find this worthwhile doing.

Note:

  • the encryption of a buzhash64 current sum value must only depend on the sum value and the encryption key, NOT on the position in the current stream (thus: no AES-CTR or any other cipher that does not independently encrypt blocks, this is why ECB is used here) - otherwise it would cut the chunks not only based on the content but also based on position in the stream and that would cut differently and would destroy deduplication.
  • instead of encrypting just 64bit using ECB, we could collect e.g. 1024 sums, encrypt them all on in one .encrypt_many() call and then do another loop over the esums to decide where to cut. would be much less overhead than now, but needs maintaining yet another buffer efficiently.

@codecov
Copy link

codecov bot commented Jun 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.03%. Comparing base (14c2153) to head (caa9fdc).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8920      +/-   ##
==========================================
- Coverage   75.04%   75.03%   -0.02%     
==========================================
  Files          86       86              
  Lines       15318    15319       +1     
  Branches     2275     2275              
==========================================
- Hits        11496    11495       -1     
  Misses       3178     3178              
- Partials      644      646       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@darkk
Copy link

darkk commented Jun 24, 2025

(As a sidenote on speed). I've found it quite interesting that fast PCG RNG (numpy's default prng) is predictable, but seed reconstruction out of 64 consecutive values is a non-trivial operation — 2¼ CPU-years of computation. However, it's still just a €108, if we assume a CPU core to cost 4 €/month.

Encrypting the rolling hash should make it better resist against attacks.

use aes128-ecb (slow, not optimized)
this will detect if there is anything going wrong
regarding deduplication with the encrypted buzhash mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants